Skip to content

Conversation

@quinncomendant
Copy link
Contributor

Updated Client so the constructor accepts an array of options which override default options. This allows additional configuration of the HttpClient (e.g., to change 'base_url' to sandbox URL, 'debug', and 'timeout').

…verride default options. This allows additional configuration of the HttpClient (e.g., to change 'base_url' to sandbox URL, 'debug', and 'timeout').
…Service->exec() to allow specifying http method (these services require POST requests).
…s for these services forgot to be added during previous commit.)
…Service->exec() to allow specifying http method (these services require POST requests).
…s for these services forgot to be added during previous commit.)
…too quickly.

Nexmo will reject requests if they are submitted too quickly with a "429 Too Many Requests" error. The limit for the Developer API is 3 requests per second, and the SMS and Voice APIs limit at 30 requests per second (except US/Canada, it's 1 request per second). Details at https://help.nexmo.com/hc/en-us/articles/203993598

This commit includes changes to use a RateLimitSubscriber, which is a native hook for the Guzzle HTTP client. It times the previous request, and if it is faster than the minimum to stay below the rate limit, it will sleep long enough so the second request does not violate the rate limit. SMS and Voice requests are timed on a per-LVN basis so the delay will only occur when sending from the same LVN too quickly would trigger the limit, but sending from different LVNs will still be fast. Each service class is given a getRateLimit() method which returns the limit for that specific API endpoint.
…ich are outside the GSM default character set.

Nexmo claims to be able to support the GSM 03.38 Basic Character Set <http://unicode.org/Public/MAPPINGS/ETSI/GSM0338.TXT> in text (not unicode) messages. Here, I've changed this method to test specifically for these. The old method fails because many of these characters are outside the normal ASCII range, and because the characters cannot be converted safely using ord() and str_split().
…relax the validation to avoid throwing exceptions during perfectly valid API responses.

* In Account/Numbers.php we end validation if the count is zero, which can occur if the account has no numbers attached. Also, removed the validation for moHttpUrl because this value may not exist if a number has been added without one (in which case the account's default moHttpUrl will be used).
* In Account/Pricing/Country.php the country parameter should always be uppercase (Nexmo will error if it is not). Also, some countries to not have a 'mt' price value set (e.g., BV) so we can't freak out if it is missing.
Conflicts:
	src/Service/Service.php
@vood
Copy link
Contributor

vood commented Sep 8, 2015

Please check unit test failures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants